<!DOCTYPE HTML>
<html>
<head>
<include file="Include:meta" />
<title>营销计划-目的地运营集团数据管理平台</title>
<include file="Include:style" />
<style>
	.hides{ display: none !important; }
	.ke-dialog-row:last-child{ display: none; }
</style>
</head>
<body>
<include file="Include:header" />
<include file="Include:left" />
<div id="main">
	<div class="crumbs">
		<div class="crumbs-text"><if condition="$project['info_id'] neq NULL">商务跟进</if>项目 > [{$project['project_num']}]{$project['project_name']} > 营销计划</div>
	</div>
	<div id="content">
		<include file="Include:project_header" />
		<form method="post" name="number_validate" id="password_validate" novalidate="novalidate">
			<div class="form-main">
				<div class="form-title">营销计划</div>
				<div class="form-table-item over_none">
					<table class="table">
						<tbody>
							<tr class="form-table-header">
								<td width="15%">
								<select name="type" class="form-control w150">
									<option value="-10"<if condition="$type eq -10"> selected</if>>计划分类</option>
									<foreach name="type_name" item="vo">
									<option value="{$vo['name2']}" <if condition="$type eq $vo['name2']">selected</if>>{$vo['name1']}</option>
									</foreach>
								</select>
								</td>
								<td width="15%">时间阶段</td>
								<td width="50%">附件</td>
								<td width="15%">状态</td>
								<if condition="((((get_permission($qs,NULL,3)) and ($project['add_uid'] eq $login_id)) or (get_permission($qs,NULL,2) and (in_array($project['center_id'],$manage_id))) or (get_permission($qs,NULL,1))) or ($project['director_uid'] eq $login_id) or ($project['manager_uid'] eq $login_id)) and ($project['status'] eq 1)">
								<td width="5%">管理</td>
								</if>
							</tr>
							<if condition="$result eq NULL">
							<tr>
								<td class="text-center" <if condition="((((get_permission($qs,NULL,3)) and ($project['add_uid'] eq $login_id)) or (get_permission($qs,NULL,2) and (in_array($project['center_id'],$manage_id))) or (get_permission($qs,NULL,1))) or ($project['director_uid'] eq $login_id) or ($project['manager_uid'] eq $login_id)) and ($project['status'] eq 1)">colspan="5"<else/>colspan="4"</if>>暂无相关数据</td>
							</tr>
							</if>
							<foreach name="result" item="vo">
								<tr class="interlaced-color">
									<td>{$vo['type_name']}</td>
									<td>{$vo['time_stage']}</td>
									<td>
									<foreach name="vo['file_url']" item="vv" key="vkey">
									{$vo['file_name'][$vkey]}<a href="{$vv}" did="{$vo['id']}" target="_blank" data-toggle="tooltip" data-placement="right" title="下载" class="ml5 mr15"><i class="glyphicon glyphicon-download-alt"></i></a>
									</foreach>
									</td>
									<td style="padding:0" class="ding">
										<div class="project_user_alert">
											<if condition="$vo['status'] eq -1">未提交<if condition="$vo['back_user'] neq NULL"><span title="{$vo['back_user']}({$vo['back_date']|substr=0,10}):{$vo['back_to_resaon']}" data-placement="left" data-toggle="tooltip" class="red">(已打回)<span></if>
											<elseif condition="$vo['status'] eq 4"/>已完结<i class="glyphicon glyphicon-exclamation-sign ml10" style="color:#999"></i>
											<else />
												<if condition="$vo['status'] eq 1">待【{$vo['audit_user']}】审核<i class="glyphicon glyphicon-exclamation-sign ml10" style="color:#999"></i>
												<elseif condition="$vo['status'] eq 2"/>待【{$vo['audit_user']}】审核<i class="glyphicon glyphicon-exclamation-sign ml10" style="color:#999"></i>
												<elseif condition="$vo['status'] eq 3"/>待【{$vo['audit_user']}】审核<i class="glyphicon glyphicon-exclamation-sign ml10" style="color:#999"></i>
												</if>
											</if>
											<if condition="$vo['status'] gt -1">
											<div class="project_user_box">
												<if condition="$vo['status'] neq -1">
													<div class="project_user_title">审核流程</div>
													<foreach name="vo['audit_arr']" item="vv">
														<div class="p"><span class="bold">{$vv['audit_name']}</span>
														<if condition="$vv['audit_date'] neq NULL">
															<span>{$vv['audit_user']}({$vv['audit_date']|substr=0,10})<if condition="$vv['audit_comments'] neq NULL">:{$vv['audit_comments']}</if></span>
															<if condition="$vv['dh_message'] neq NULL"><br/><span>打回至"{$vv['arrive_name']}"({$vv['dh_date']|substr=0,10})原因:{$vv['dh_message']}</span></if><if condition="$vv['arrive_info'] neq NULL"><br/><span>"{$vv['arrive_name']}"({$vv['arrive_date']|substr=0,10})回复:{$vv['arrive_info']}</span></if>
														<else/>
															<span class='red'>[未审核]{$vv['audit_user']}</span>
															<if condition="$vv['dh_message'] neq NULL"><br/><span class='red'>打回至"{$vv['arrive_name']}"({$vv['dh_date']|substr=0,10})原因:{$vv['dh_message']}</span></if><if condition="$vv['arrive_info'] neq NULL"><br/><span class='red'>"{$vv['arrive_name']}"({$vv['arrive_date']|substr=0,10})回复:{$vv['arrive_info']}</span></if>
														</if>
														</div>
													</foreach>
												</if>
												<!--<if condition="$vo['back_user'] neq NULL">
													<div class="p"><span class="red bold">打回原因 </span><span class="red">{$vo['back_user']}({$vo['back_date']|substr=0,10}):{$vo['back_to_resaon']}</span></div>
												</if>
												<if condition="$vo['submit_info'] neq NULL">
													<div class="p"><span class="red bold">重新提交 </span><span class="red">{$vo['submit_user']}:{$vo['submit_info']}</span></div>
												</if>-->
											</div>
											</if>
										</div>
									</td>
									<if condition="((((get_permission($qs,NULL,3)) and ($project['add_uid'] eq $login_id)) or (get_permission($qs,NULL,2) and (in_array($project['center_id'],$manage_id))) or (get_permission($qs,NULL,1))) or ($project['director_uid'] eq $login_id) or ($project['manager_uid'] eq $login_id)) and ($project['status'] eq 1)">
									<td>
										<if condition="$vo['status'] eq -1">
											<if condition="$vo['back_to_resaon'] neq '' and $vo['arrive_status'] eq -1">
												<a href="javascript:;" mid="{$vo['id']}" data-toggle="tooltip" data-placement="left" title="重新提交" class="btn-rest-submit ml5"><i class="glyphicon glyphicon-ok"></i></a>
											<else/>
												<a href="javascript:;" mid="{$vo['id']}" data-toggle="tooltip" data-placement="left" title="提交" class="btn-submit ml5"><i class="glyphicon glyphicon-ok"></i></a>
											</if>
										<a href="javascript:;" mid="{$vo['id']}" action="delete" data-toggle="tooltip" data-placement="left" title="删除" class="btn-delete ml5"><i class="glyphicon glyphicon-trash"></i></a>
										<elseif condition="$vo['status'] eq 1"/>
										<a href="javascript:;" mid="{$vo['id']}" data-toggle="tooltip" data-placement="left" title="放弃提交" class="btn-remove ml5"><i class="glyphicon glyphicon-remove"></i></a>
										</if>
									</td>
									</if>
								</tr>
							</foreach>
						</tbody>
					</table>
				</div>
				<if condition="((((get_permission($qs,NULL,3)) and ($project['add_uid'] eq $login_id)) or (get_permission($qs,NULL,2) and (in_array($project['center_id'],$manage_id))) or (get_permission($qs,NULL,1))) or ($project['director_uid'] eq $login_id) or ($project['manager_uid'] eq $login_id)) and ($project['status'] eq 1)">
				<div class="form-title">添加营销计划</div>
				<div class="form-item">
					<div class="input-label"><span class="asterisk">*</span>计划分类</div>
					<div class="input-item">
						<select name="plan" class="form-control required-selted" autocomplete="off">
							<option value="-10" selected>请选择</option>
							<foreach name="type_name" item="vo">
							<option value="{$vo['name2']}" >{$vo['name1']}</option>
							</foreach>
						</select>
						<span class="error-item">必填项</span>
						
					</div>
				</div>
				<div class="form-item">
					<div class="input-label"><span class="asterisk">*</span>时间阶段</div>
					<div class="input-item">
						<select name="year" class="form-control required-selted" autocomplete="off">
							<foreach name="year" item="vo">
							<option value="{$vo}年" <if condition="substr($today,0,4) eq $vo">selected</if>>{$vo}年</option>
							</foreach>
						</select>
						<select name="quarter" class="form-control required-selted" autocomplete="off">
							<option value="-10" selected>请选择</option>
						</select>
						<span class="error-item">必填项</span>
					</div>
				</div>
				<foreach name="plan_m" item="vo">
				<div class="form-item hide list1">
					<div class="input-label"><if condition="$key eq 0"><span class="asterisk">*</span>模板下载上传</if></div>
					<div class="input-item">
						<div class="input-group w250 left">
							<input type="text" class="form-control name_inp" name="name_inp[]" placeholder="请上传附件" readonly>
							<input type="text" name="file_name[]" class="form-control file-name hides" placeholder="请上传附件" readonly autocomplete="off">
							<span class="input-group-btn">
								<button class="btn file-submit" type="button">上传</button>
							</span>
						</div>
						<button class="btn file-delete ml5 hide left" type="button">删除</button>
						<input type="hidden" name="file_url[]" class="file-url" autocomplete="off">
						<span class="ml20 left txt">{$vo['name1']}</span><a href="{$vo['name3']}" target="_blank" data-toggle="tooltip" data-placement="right" title="下载" class="ml5"><i class="glyphicon glyphicon-download-alt"></i></a>
						<span class="error-item">文件名必填</span>
						<span class="error-item">必填项</span>
					</div>
				</div>
				</foreach>
				<foreach name="plan_j" item="vo">
				<div class="form-item hide list2">
					<div class="input-label"><if condition="$key eq 0"><span class="asterisk">*</span>模板下载上传</if></div>
					<div class="input-item">
						<div class="input-group w250 left">
							<input type="text" class="form-control name_inp" name="name_inp[]" placeholder="请上传附件" readonly>
							<input type="text" name="file_name[]" class="form-control file-name hides" placeholder="请上传附件" readonly autocomplete="off">
							<span class="input-group-btn">
								<button class="btn file-submit" type="button">上传</button>
							</span>
						</div>
						<button class="btn file-delete ml5 hide left" type="button">删除</button>
						<input type="hidden" name="file_url[]" class="file-url" autocomplete="off">
						<span class="ml20 left txt">{$vo['name1']}</span><a href="{$vo['name3']}" target="_blank" data-toggle="tooltip" data-placement="right" title="下载" class="ml5"><i class="glyphicon glyphicon-download-alt"></i></a>
						<span class="error-item">文件名必填</span>
						<span class="error-item">必填项</span>
					</div>
				</div>
				</foreach>
				<foreach name="plan_y" item="vo">
				<div class="form-item hide list3">
					<div class="input-label"><if condition="$key eq 0"><span class="asterisk">*</span>模板下载上传</if></div>
					<div class="input-item">
						<div class="input-group w250 left">
							<input type="text" class="form-control name_inp" name="name_inp[]" placeholder="请上传附件" readonly>
							<input type="text" name="file_name[]" class="form-control file-name hides" placeholder="请上传附件" readonly autocomplete="off">
							<span class="input-group-btn">
								<button class="btn file-submit" type="button">上传</button>
							</span>
						</div>
						<button class="btn file-delete ml5 hide left" type="button">删除</button>
						<input type="hidden" name="file_url[]" class="file-url" autocomplete="off">
						<span class="ml20 left txt">{$vo['name1']}</span><a href="{$vo['name3']}" target="_blank" data-toggle="tooltip" data-placement="right" title="下载" class="ml5"><i class="glyphicon glyphicon-download-alt"></i></a>
						<span class="error-item">文件名必填</span>
						<span class="error-item">必填项</span>
					</div>
				</div>
				</foreach>
				<foreach name="plan_z" item="vo">
				<div class="form-item hide list4">
					<div class="input-label"><if condition="$key eq 0"><span class="asterisk">*</span>模板下载上传</if></div>
					<div class="input-item">
						<div class="input-group w250 left">
							<input type="text" class="form-control name_inp" name="name_inp[]" placeholder="请上传附件" readonly>
							<input type="text" name="file_name[]" class="form-control file-name hides" placeholder="请上传附件" readonly autocomplete="off">
							<span class="input-group-btn">
								<button class="btn file-submit" type="button">上传</button>
							</span>
						</div>
						<button class="btn file-delete ml5 hide left" type="button">删除</button>
						<input type="hidden" name="file_url[]" class="file-url" autocomplete="off">
						<span class="ml20 left txt">{$vo['name1']}</span><a href="{$vo['name3']}" target="_blank" data-toggle="tooltip" data-placement="right" title="下载" class="ml5"><i class="glyphicon glyphicon-download-alt"></i></a>
						<span class="error-item">文件名必填</span>
						<span class="error-item">必填项</span>
					</div>
				</div>
				</foreach>
				<div class="form-btn-item"><button class="btn submit" type="button">生成</button></div>
				</if>
			</div>
		</form>
	</div>
</div>
<!--重新提交框-->
<div class="modal fade" id="myModal_submit">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<h4>重新提交</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body">
				<table class="table table-bordered">
					<tr>
						<td class="text-right"><strong><span class="asterisk">*</span>原因</strong></td>
						<td>
							<textarea name="remark" placeholder="重新提交理由" class="form-control w300 submit_info left" autocomplete="off"></textarea>
							<span class="error-item left">必填项</span>
						</td>
					</tr>
				</table>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-affirm">确认</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>
<include file="Include:javascript" />
<script>
$(function(){
	$('.relative').hover(function(){
		$(this).find('.tooltip_cont').toggleClass('active');
	})
	$(document).on("change","[name='type']",function(){
		var val = $(this).val();
		window.location.href="__APP__/Project/project_plan/id/{$project['id']}/type/"+val;
	});
	KindEditor.ready(function(K){
		//上传附件
		var editorFile = K.editor();
		$('.file-submit').on('click',function(){
			var parents = $(this).parents(".input-group");
			editorFile.loadPlugin('insertfile',function(){
				document.cookie="file_name=project_plan";
				document.cookie="file_type=ppt,pptx,pdf,doc,docx,jpg,jpeg,png,xls,xlsx,txt,rar,zip";
				editorFile.plugin.fileDialog({
					clickFn:function(url,title){
						parents.nextAll(".error-item").hide();
						var html = parents.siblings('.txt').html();
						parents.find('.name_inp').val(html);
						parents.find(".file-name").val(title).prop("readonly",false);
						parents.nextAll(".file-url").val(url);
						parents.nextAll(".file-delete").show();
						editorFile.hideDialog();
					}
				});
			});
		});
	});
	//删除附件
	$(".file-delete").click(function(){
		$(this).hide();
		$(this).nextAll(".error-item").hide();
		$(this).nextAll(".file-url").val("");
		$(this).prevAll(".input-group").find(".file-name").val("").prop("readonly",true);
		$(this).parents("tr").find(".required-text2").next(".error-item").hide();
		$(this).siblings('.input-group').find('.name_inp').val('');
	});
	//计划分类
	var year = $("[name='year']").html();
	$("[name='plan']").change(function(){
		var val = $(this).val();
		if(val==-10){
			$("[name='year']").html(year);
			$("[name='quarter']").show().select2().html('<option value="-10" selected>请选择</option>')
			$('.form-item.hide').hide().removeClass('show');
		}
		if(val==1){
			$("[name='year']").html(year);
			$("[name='quarter']").show().select2().html('<option value="-10" selected>请选择</option><option value="12月">12月</option><option value="11月">11月</option><option value="10月">10月</option><option value="9月">9月</option><option value="8月">8月</option><option value="7月">7月</option><option value="6月">6月</option><option value="5月">5月</option><option value="4月">4月</option><option value="3月">3月</option><option value="2月">2月</option><option value="1月">1月</option>');
			$('.form-item.hide').hide().removeClass('show');
			$('.list1').show().addClass('show');
		}
		if(val==2){
			$("[name='year']").html(year);
			$("[name='quarter']").show().select2().html('<option value="-10" selected>请选择</option><option value="第4季度">第4季度</option><option value="第3季度">第3季度</option><option value="第2季度">第2季度</option><option value="第1季度">第1季度</option>');
			$('.form-item.hide').hide().removeClass('show');
			$('.list2').show().addClass('show');
		}
		if(val==3){
			$("[name='year']").html(year);
			$("[name='quarter']").hide().next('.select2').remove();
			$('.form-item.hide').hide().removeClass('show');
			$('.list3').show().addClass('show');
		}
		if(val==4){
			$("[name='year']").html('<option value="1" selected>专项</option>');
			$("[name='quarter']").hide().next('.select2').remove();
			$('.form-item.hide').hide().removeClass('show');
			$('.list4').show().addClass('show');
		}
		$(".file-delete").click();
	})
	
	//删除项目过程文件
	$(".btn-delete").ajaxModal({"title_text":"确认提示框","body_text":"您确定要删除吗？","url":"__APP__/Project/project_plan_ajax","data":{"id":"mid","action":"action"}});
	
	//提交
	$(".btn-submit").on("click",function(){
		var mid = $(this).attr("mid");
		$.ajax({
			type:"POST",
			async:false,
			dataType:"json",
			data:{"mid":mid,"status":"up"},
			url:"__APP__/Project/project_plan_audit",
			success:function(data){
				success_pop(data.status,data.msg);
			}
		});
	});
	
	//放弃提交
	$(".btn-remove").on("click",function(){
		var mid = $(this).attr("mid");
		$.ajax({
			type:"POST",
			async:false,
			dataType:"json",
			data:{"mid":mid,"status":"giveup"},
			url:"__APP__/Project/project_plan_audit",
			success:function(data){
				success_pop(data.status,data.msg);
			}
		});
	});
	//提交验证
	$(".submit").on('click',function(){
		var tag = true;
		
		$("[name='plan']").each(function(){
			var val = $(this).val();
			if(val==-10){
				$(this).parent().find('.error-item').show();
				tag = false;
			}
		})
		$("[name='quarter']").each(function(){
			var val = $(this).val();
			if(val==-10){
				$(this).parent().find('.error-item').show();
				tag = false;
			}
		})
		$(".show .file-name").each(function(){
			var val = $(this).val();
			
			if($(this).prop("readonly")){
				$(this).parents(".input-group").nextAll(".error-item").eq(1).show();
				tag = false;
			}else if((val=="" || /^\s+$/.test(val)) && !$(this).prop("readonly")){
				$(this).parents(".input-group").nextAll(".error-item").eq(0).show();
				tag = false;
			}
		});
		$(".file-url").each(function(){
			var val = $(this).val();
			if(val!=""){
				$(this).parents("tr").find(".required-text2").each(function(){
					var val2 = $(this).val();
					if(val2=="" || /^\s+$/.test(val2)){
						$(this).next(".error-item").show();
						tag = false;
					}
				});
			}
		});
		if(tag){
			var communicate_add = 'add',
				pid = "{$project['id']}";
			$.ajax({
				type:"POST",
				async:false,
				dataType:"json",
				data:$("[name='number_validate']").serialize()+"&action="+communicate_add+"&pid="+pid,
				url:"__APP__/Project/project_plan_ajax",
				success:function(data){
					success_pop(data.status,data.msg);
				}
			});
		}
	});
	/*重新提交*/
	$(".btn-rest-submit").click(function(){
		var mid = $(this).attr("mid");

		$("#myModal_submit .btn-affirm").attr("mid",mid);
		$(".submit_info").removeClass("red").val("");
		$('#myModal_submit').modal('toggle');
	});
	
	$("#myModal_submit .btn-affirm").click(function(){
		var mid = $(this).attr("mid"),
			submit_info = $(".submit_info").val();

		if(submit_info==""||submit_info=="重新提交理由必填"){
			$(".submit_info").addClass("red").val("重新提交理由必填");
		}else{
			$('#myModal_submit').hide();
			$.ajax({
				cache:true,
				type:"POST",
				dataType:"json",
				global: false,
				url:"__APP__/Project/project_plan_audit",
				data:{"mid":mid,"status":"up","submit_info":submit_info},
				success:function(data){
					success_pop(data['status'],data['msg']);
				}
			});
		}
	});

	$(".submit_info").focus(function(){
		if($(this).val()=="重新提交理由必填"){
			$(this).removeClass("red").val("");
		}
	});
	//隐藏错误提示
	$("[name='quarter'],[name='plan']").change(function(){
		$(this).parent().find('.error-item').hide();
	})
	$('.file-name').focus(function(){
		$(this).parents('.input-item').find('.error-item').hide();
	})
})
</script>
</body>
</html>